﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MySql.Data.MySqlClient;

namespace MulagoDb
{
    public partial class MulagoMain : Form
    {
        public PatientReg patientRegControl = new PatientReg();
        public DiagnosisPanel diagnosisControl = new DiagnosisPanel();
        public ClinicVisitPanel clinicVisitControl = new ClinicVisitPanel();
        public FileClosure fileClosureControl = new FileClosure();
        public Hospitalization hospitalizationControl = new Hospitalization();
        public ProblemListPanel problemListControll = new ProblemListPanel();
        public ReportsPanel reportsPanelControl = new ReportsPanel();
        public FamilyStudyControl familyStudyControl = new FamilyStudyControl();
        public static PatientRegistration database = new PatientRegistration();

        public MulagoMain()
        {
            InitializeComponent();
            patientRegControl.Dock = DockStyle.Fill;
            diagnosisControl.Dock = DockStyle.Fill;
            clinicVisitControl.Dock = DockStyle.Fill;
            fileClosureControl.Dock = DockStyle.Fill;
            hospitalizationControl.Dock = DockStyle.Fill;
            problemListControll.Dock = DockStyle.Fill;
            reportsPanelControl.Dock = DockStyle.Fill;
            familyStudyControl.Dock = DockStyle.Fill;
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (FindPatient.patienceName.Equals(""))
            {
                if (!centerPanel.Contains(patientRegControl))
                    centerPanel.Controls.Add(patientRegControl);
                patientRegControl.BringToFront();
                patientRegControl.Dock = DockStyle.Fill;
            }
            else {
                if (!centerPanel.Contains(patientRegControl))
                {
                    centerPanel.Controls.Add(patientRegControl);
                }
                patientRegControl.BringToFront();
                patientRegControl.pupulatePatientReg(FindPatient.patientId);
                patientRegControl.Dock = DockStyle.Fill;
            }
        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //PatientRegistration.addPatients("kakama", "victor");
            //PatientRegistration.addPatients("zimwe", "Edson");
        }

        private void patientRegLbl_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = SystemColors.HighlightText;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = Color.SteelBlue;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Black;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Transparent;
            if (!centerPanel.Contains(patientRegControl))
                centerPanel.Controls.Add(patientRegControl);
            patientRegControl.BringToFront();
            patientRegControl.Dock = DockStyle.Fill;
        }

        private void patientregPanel_Paint(object sender, PaintEventArgs e)
        {
            
        }

        private void diagPanel_Paint(object sender, PaintEventArgs e)
        {
            
        }

        private void panel2_Paint(object sender, PaintEventArgs e)
        {

        }

        private void familyPanel_Paint(object sender, PaintEventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = SystemColors.HighlightText;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = Color.SteelBlue;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Black;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Transparent;
            if (!centerPanel.Contains(familyStudyControl))
                centerPanel.Controls.Add(familyStudyControl);
            familyStudyControl.BringToFront();
            familyStudyControl.Dock = DockStyle.Fill;
        }

        private void label1_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = SystemColors.HighlightText;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = Color.SteelBlue;
            label1.ForeColor = Color.Black;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Transparent;

            if (!centerPanel.Contains(diagnosisControl))
                centerPanel.Controls.Add(diagnosisControl);
            diagnosisControl.BringToFront();
            diagnosisControl.Dock = DockStyle.Fill;
        }

        private void label3_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = SystemColors.HighlightText;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = Color.SteelBlue;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Black;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Transparent;

            if (!centerPanel.Contains(hospitalizationControl))
                centerPanel.Controls.Add(hospitalizationControl);
            hospitalizationControl.BringToFront();
            hospitalizationControl.Dock = DockStyle.Fill;
        }

        private void label4_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = SystemColors.HighlightText;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = Color.SteelBlue;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Black;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Transparent;

            if (!centerPanel.Contains(problemListControll))
                centerPanel.Controls.Add(problemListControll);
            problemListControll.BringToFront();
            problemListControll.Dock = DockStyle.Fill;
        }

        private void label5_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = SystemColors.HighlightText;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = Color.SteelBlue;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Black;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Transparent;

            if (!centerPanel.Contains(clinicVisitControl))
                centerPanel.Controls.Add(clinicVisitControl);
            clinicVisitControl.BringToFront();
            clinicVisitControl.Dock = DockStyle.Fill;
        }

        private void label6_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = SystemColors.HighlightText;
            filePanel.BackColor = Color.SteelBlue;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Black;
            label7.ForeColor = Color.Transparent;
            if (!centerPanel.Contains(reportsPanelControl))
                centerPanel.Controls.Add(reportsPanelControl);
            reportsPanelControl.BringToFront();
            reportsPanelControl.Dock = DockStyle.Fill;
        }

        private void label7_Click(object sender, EventArgs e)
        {
            patientregPanel.BackColor = Color.SteelBlue;
            diagPanel.BackColor = Color.SteelBlue;
            familyPanel.BackColor = Color.SteelBlue;
            hospitalPanel.BackColor = Color.SteelBlue;
            problemPanel.BackColor = Color.SteelBlue;
            cliinicPanel.BackColor = Color.SteelBlue;
            reportsPanel.BackColor = Color.SteelBlue;
            filePanel.BackColor = SystemColors.HighlightText;
            //change label colors
            label1.ForeColor = Color.Transparent;
            label0.ForeColor = Color.Transparent;
            label2.ForeColor = Color.Transparent;
            label3.ForeColor = Color.Transparent;
            label4.ForeColor = Color.Transparent;
            label5.ForeColor = Color.Transparent;
            label6.ForeColor = Color.Transparent;
            label7.ForeColor = Color.Black;
            if (!centerPanel.Contains(fileClosureControl))
                centerPanel.Controls.Add(fileClosureControl);
            fileClosureControl.BringToFront();
            fileClosureControl.Dock = DockStyle.Fill;
        }

        private void panel4_Paint(object sender, PaintEventArgs e)
        {
           // centerPanel.Controls.Add(patientRegControl);
        }

        private void panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void panel6_Paint(object sender, PaintEventArgs e)
        {

        }

        private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void searchToolStripMenuItem_Click(object sender, EventArgs e)
        {
            new Search().Show();
        }

        private void panel3_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
